function Item(data)
{
	this.marker = null;
    this.uid = data['uid'];
    this.id = data['id'];
        this.title = data['title'];
        this.description = data['description'];
        this.price = data['price'];
        this.lat = data['lat'];
        this.lng = data['lng'];
        this.latlng = null;
        //this.latlng = new L.LatLng(this.lat,this.lng);
        this.distance = 0;
        this.username = data['username'];
        this.added = data['added'];
        this.modified = data['modified'];
        this.imgURL = data['imgURL'];
        //var latlng = ; //format Leaflet
        
        // user object
       // var user = new User(data);
        
        this.setMarker = function(leafletMarker)
        {
                this.marker = leafletMarker;
        };
        
        /*
         * coordinates: array[lat,lng]
         */
        this.setDistance = function(coordinates)
        {
                this.distance = this.latlng.distanceTo(coordinates);
        };
        
        this.update = function(data)
        {
    		$.ajax({
    			type: 'POST',
    			url: 'I/update',
    			data: {'id' : thing_id, 'title': title, 'description': description, 'price': price, 'lat': lat, 'lng': lng, 'imgURL': imgURL},
    			timeout: 3000,
    			success: function(data) {
    				if(data == 'success')
    				{
    					ObjectManager.get();
    					/*registrationMarker.closePopup();
    		    		registrationLayer.clearLayers();*/
    		    		cancelRegistration();
    		    		display_alert('The item has been added', '#alert_area', 'success');
    				}
    				else if(data == 'fail_login')
    				{
    					display_alert('You must be logged to add an item', '#alert_area', 'error');
    				}
    				else if(data == 'fail_form')
    				{
    					display_alert('You wrote something wrong', '#alert_area', 'error');
    				}
    				else
    				{
    					display_alert('The item hasn\'t been added', '#alert_area', 'error');
    				}
    			},
    	        error: function() { display_alert('connexion problem', '#alert_area', 'error'); }
    		});
    		
    		// reset the array containing the url of the uploaded picture
    		imgURL.length = 0;
    	}
}